$("header").load("header.html");
$("footer").load("footer.html");
let oList = document.getElementsByClassName("product-tw")
let index = 0;
for (let i = 0; i < oList.length; i++) {
    oList[i].onclick = function () {
        index = i;
        if (index == 0) {
            location.href = "details.html";
        }
    }
}
//轮播图接口
$(function () {
    $.ajax({
        type: "get",
        url: "../php/bannerGet.php",
        success: function (resText) {
            const a = JSON.parse(resText)
            a.forEach((v, i) => {
                $('.swiper-wrapper').append(`<div class="swiper-slide"><img src="${v.img}"></div>`);
            });
            var mySwiper = new Swiper('.swiper', {
                direction: 'horizontal',
                loop: true, // 循环模式选项
                spaceBetween: 30,
                centeredSlides: true,
                // 如果需要分页器
                pagination: {
                    el: '.swiper-pagination',
                    clickable: true,
                    bulletActiveClass: 'my-bullet-active',
                },
                // 如果需要前进后退按钮
                navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                },
                autoplay: {
                    delay: 2000,
                    disableOnInteraction: false,
                },
            })
        }
    })
})